import axios from 'axios'
// export const BASE_URL = 'http://172.18.36.2:9090/'
export const BASE_URL = 'http://127.0.0.1:9090/'

axios.defaults.baseURL = BASE_URL

// 设置请求超时
axios.defaults.timeout = 50000
// 设置请求方式首先get请求
// 两个参数 url地址 params进行操作resolive="请求成功",reject="请求失败"
export function get(url, params) {
  return new Promise((resolve, reject) => {
    axios.get(url, { params: params }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// post请求方式道理同上
export function post(url, params) {
  return new Promise((resolve, reject) => {
    axios.post(url, params).then(res => {
      resolve(res.data)
    }).catch(err => {
      reject(err.data)
    })
  })
}
